<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html>
<head>
  <title>get_the_col_spec_for_single_col (app_wide_methods.rb)</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
</head>
<body class="standalone-code">
  <pre><span class="ruby-comment cmt"># File app_wide_methods.rb, line 8</span>
 <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">get_the_col_spec_for_single_col</span>(<span class="ruby-identifier">column_name</span>,<span class="ruby-identifier">table_name</span>,<span class="ruby-identifier">new_connection</span>)
        <span class="ruby-identifier">col_struc</span> = <span class="ruby-identifier">new_connection</span>.<span class="ruby-identifier">query</span>(<span class="ruby-node">&quot;desc #{table_name}&quot;</span>)
        <span class="ruby-identifier">column_name</span> = <span class="ruby-identifier">column_name</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp re">/_/</span>,<span class="ruby-value str">' '</span>)
        <span class="ruby-identifier">col_struc</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">col</span><span class="ruby-operator">|</span>
                <span class="ruby-identifier">col</span>[<span class="ruby-value">0</span>] = <span class="ruby-identifier">col</span>[<span class="ruby-value">0</span>].<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp re">/_/</span>,<span class="ruby-value str">' '</span>)
                <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">col</span>[<span class="ruby-value">0</span>] <span class="ruby-operator">==</span> <span class="ruby-identifier">column_name</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">col</span>[<span class="ruby-value">0</span>].<span class="ruby-identifier">upcase</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">column_name</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">col</span>[<span class="ruby-value">0</span>].<span class="ruby-identifier">downcase</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">column_name</span>
                        <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">col</span>[<span class="ruby-value">1</span>]
                <span class="ruby-keyword kw">end</span>   
        <span class="ruby-keyword kw">end</span>    
  <span class="ruby-keyword kw">end</span></pre>
</body>
</html>